
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>php数据类型 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="05_php常量.html" />
    
    
    <link rel="prev" href="03_php变量.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    前言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="01_php介绍.html">
            
                <a href="01_php介绍.html">
            
                    
                    php基础
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="01_php介绍.html">
            
                <a href="01_php介绍.html">
            
                    
                    php介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="02_PHP基础语法.html">
            
                <a href="02_PHP基础语法.html">
            
                    
                    php基础语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="03_php变量.html">
            
                <a href="03_php变量.html">
            
                    
                    php变量
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.2.4" data-path="04_php数据类型.html">
            
                <a href="04_php数据类型.html">
            
                    
                    php数据类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="05_php常量.html">
            
                <a href="05_php常量.html">
            
                    
                    php常量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="06_php运算符.html">
            
                <a href="06_php运算符.html">
            
                    
                    php运算符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="07_php流程控制.html">
            
                <a href="07_php流程控制.html">
            
                    
                    php流程控制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8" data-path="08_php数组.html">
            
                <a href="08_php数组.html">
            
                    
                    php数组
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9" data-path="09_php函数.html">
            
                <a href="09_php函数.html">
            
                    
                    php函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.10" data-path="10_php面向对象.html">
            
                <a href="10_php面向对象.html">
            
                    
                    php面向对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.11" data-path="11_php命名空间.html">
            
                <a href="11_php命名空间.html">
            
                    
                    php命名空间
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.12" data-path="12_php日期和时间.html">
            
                <a href="12_php日期和时间.html">
            
                    
                    php日期时间
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.13" data-path="13_php表单.html">
            
                <a href="13_php表单.html">
            
                    
                    php表单
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.14" data-path="14_php包含文件.html">
            
                <a href="14_php包含文件.html">
            
                    
                    php包含文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.15" data-path="15_php常用函数.html">
            
                <a href="15_php常用函数.html">
            
                    
                    php常用函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.16" data-path="../php高级/16_php常用变量函数.md">
            
                <span>
            
                    
                    php常用变量函数
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../php高级/01_php错误与异常.html">
            
                <a href="../php高级/01_php错误与异常.html">
            
                    
                    php错误与异常
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../php高级/02_PhpStorm本地断点调试.html">
            
                <a href="../php高级/02_PhpStorm本地断点调试.html">
            
                    
                    PhpStorm本地断点调试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../php高级/03_php文件操作.html">
            
                <a href="../php高级/03_php文件操作.html">
            
                    
                    php文件操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../php高级/04_cookie机制.html">
            
                <a href="../php高级/04_cookie机制.html">
            
                    
                    cookie机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../php高级/05_session.html">
            
                <a href="../php高级/05_session.html">
            
                    
                    session
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../php高级/06_php画图.html">
            
                <a href="../php高级/06_php画图.html">
            
                    
                    php画图
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../php高级/07_php加密机制.html">
            
                <a href="../php高级/07_php加密机制.html">
            
                    
                    php加密机制
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >php数据类型</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="php&#x6570;&#x636E;&#x7C7B;&#x578B;">PHP&#x6570;&#x636E;&#x7C7B;&#x578B;</h1>
<p>&#x8BA1;&#x7B97;&#x673A;&#x987E;&#x540D;&#x601D;&#x4E49;&#x5C31;&#x662F;&#x53EF;&#x4EE5;&#x505A;&#x6570;&#x5B66;&#x8BA1;&#x7B97;&#x7684;&#x673A;&#x5668;&#xFF0C;&#x56E0;&#x6B64;&#xFF0C;&#x8BA1;&#x7B97;&#x673A;&#x7A0B;&#x5E8F;&#x7406;&#x6240;&#x5F53;&#x7136;&#x5730;&#x53EF;&#x4EE5;&#x5904;&#x7406;&#x5404;&#x79CD;&#x6570;&#x503C;&#x3002;&#x4F46;&#x662F;&#xFF0C;&#x8BA1;&#x7B97;&#x673A;&#x80FD;&#x5904;&#x7406;&#x7684;&#x8FDC;&#x4E0D;&#x6B62;&#x6570;&#x503C;&#xFF0C;&#x8FD8;&#x53EF;&#x4EE5;&#x5904;&#x7406;&#x6587;&#x672C;&#x3001;&#x56FE;&#x5F62;&#x3001;&#x97F3;&#x9891;&#x3001;&#x89C6;&#x9891;&#x3001;&#x7F51;&#x9875;&#x7B49;&#x5404;&#x79CD;&#x5404;&#x6837;&#x7684;&#x6570;&#x636E;&#xFF0C;&#x4E0D;&#x540C;&#x7684;&#x6570;&#x636E;&#xFF0C;&#x9700;&#x8981;&#x5B9A;&#x4E49;&#x4E0D;&#x540C;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x3002;</p>
<h2 id="php&#x6570;&#x636E;&#x7C7B;&#x578B;">PHP&#x6570;&#x636E;&#x7C7B;&#x578B;</h2>
<blockquote>
<p>PHP&#x4E2D;&#x6709;8&#x79CD;&#x6570;&#x636E;&#x7C7B;&#x578B;</p>
</blockquote>
<h3 id="&#x6807;&#x91CF;&#x6570;&#x636E;&#x7C7B;&#x578B;">&#x6807;&#x91CF;&#x6570;&#x636E;&#x7C7B;&#x578B;</h3>
<blockquote>
<p>var_dump()&#x51FD;&#x6570; &#x8FD4;&#x56DE;&#x53D8;&#x91CF;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x548C;&#x503C;&#x3002;</p>
</blockquote>
<p>&#x6807;&#x91CF;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x662F;&#x6570;&#x636E;&#x7ED3;&#x6784;&#x4E2D;&#x6700;&#x57FA;&#x672C;&#x7684;&#x5355;&#x5143;&#xFF0C;&#x53EA;&#x5B58;&#x50A8;&#x4E00;&#x4E2A;&#x6570;&#x636E;&#xFF0C;php&#x4E2D;&#x6807;&#x91CF;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x5305;&#x542B;&#x4EE5;&#x4E0B;&#x56DB;&#x79CD;&#xFF1A;</p>
<table>
<thead>
<tr>
<th>&#x7C7B;&#x578B;EN</th>
<th>&#x7C7B;&#x578B;CN</th>
<th>&#x503C;</th>
</tr>
</thead>
<tbody>
<tr>
<td>boolean</td>
<td>&#x5E03;&#x5C14;&#x578B;</td>
<td>true false</td>
</tr>
<tr>
<td>string</td>
<td>&#x5B57;&#x7B26;&#x4E32;&#x578B;</td>
<td>&#x5B57;&#x7B26;&#x4E32;&#x53EF;&#x4EE5;&#x662F;&#x5F15;&#x53F7;&#x5185;&#x7684;&#x4EFB;&#x4F55;&#x6587;&#x672C;&#x3002;&#x60A8;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5355;&#x5F15;&#x53F7;&#x6216;&#x53CC;&#x5F15;&#x53F7;</td>
</tr>
<tr>
<td>integer</td>
<td>&#x6574;&#x578B;</td>
<td>&#x53EA;&#x5305;&#x542B;&#x6574;&#x6570;&#x3001;&#x6B63;&#x6570;&#x3001;&#x8D1F;&#x6570;,&#x53EF;&#x4EE5;&#x7528;&#x4E09;&#x79CD;&#x683C;&#x5F0F;&#x89C4;&#x5B9A;&#x6574;&#x6570;&#xFF1A;&#x5341;&#x8FDB;&#x5236;&#x3001;&#x5341;&#x516D;&#x8FDB;&#x5236;&#xFF08;&#x524D;&#x7F00;&#x662F; 0x&#xFF09;&#x6216;&#x516B;&#x8FDB;&#x5236;&#xFF08;&#x524D;&#x7F00;&#x662F; 0&#xFF09;</td>
</tr>
<tr>
<td>float</td>
<td>&#x6D6E;&#x70B9;&#x578B;</td>
<td>&#x6D6E;&#x70B9;&#x6570;&#x662F;&#x5E26;&#x5C0F;&#x6570;&#x90E8;&#x5206;&#x7684;&#x6570;&#x5B57;&#xFF0C;&#x6216;&#x8005;&#x6307;&#x6570;&#x5F62;&#x5F0F;</td>
</tr>
</tbody>
</table>
<h4 id="boolean">boolean</h4>
<p>&#x5E03;&#x5C14;&#x578B;&#x53EF;&#x4EE5;&#x662F; TRUE &#x6216; FALSE&#x3002;</p>
<pre><code class="lang-php"><span class="hljs-comment"># &#x5E03;&#x5C14;&#x578B;</span>
<span class="hljs-comment"># &#x8981;&#x6307;&#x5B9A;&#x4E00;&#x4E2A;&#x5E03;&#x5C14;&#x503C;&#xFF0C;&#x4F7F;&#x7528;&#x5173;&#x952E;&#x5B57; TRUE &#x6216; FALSE &#x3002;&#x4E24;&#x4E2A;&#x90FD;&#x4E0D;&#x533A;&#x5206;&#x5927;&#x5C0F;&#x5199;&#x3002;</span>
<span class="hljs-meta">&lt;?php</span>
    $x = <span class="hljs-keyword">true</span>;
    $y = <span class="hljs-keyword">false</span>;
    <span class="hljs-keyword">echo</span> $x;
    <span class="hljs-keyword">echo</span> $y;
<span class="hljs-meta">?&gt;</span>
</code></pre>
<p>&#x5E03;&#x5C14;&#x578B;&#x901A;&#x5E38;&#x7528;&#x4E8E;&#x6761;&#x4EF6;&#x5224;&#x65AD;&#x3002;</p>
<h4 id="string">string</h4>
<p>&#x5B57;&#x7B26;&#x6BB5;&#x578B;&#xFF0C;&#x4F7F;&#x7528;&#x5355;&#x5F15;&#x53F7;&#x6216;&#x53CC;&#x5F15;&#x53F7;&#x5F15;&#x8D77;&#x6765;&#x7684;&#x4E00;&#x6BB5;&#x5B57;&#x7B26;&#x3002;</p>
<p><strong>&#x5E76;&#x7F6E;&#x8FD0;&#x7B97;&#x7B26;</strong></p>
<p>&#x5E76;&#x7F6E;&#x8FD0;&#x7B97;&#x7B26; (.) &#x7528;&#x4E8E;&#x628A;&#x4E24;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#x503C;&#x8FDE;&#x63A5;&#x8D77;&#x6765;&#x3002;</p>
<pre><code class="lang-php"><span class="hljs-meta">&lt;?php</span>
    $str = <span class="hljs-string">&quot;hello&quot;</span>;
    $str2 = <span class="hljs-string">&quot;&#x4F60;&#x597D;&quot;</span>;
    <span class="hljs-keyword">echo</span> $str.<span class="hljs-string">&apos;&#x7FFB;&#x8BD1;&#x8FC7;&#x6765;&#x662F;&#xFF1A;&apos;</span>.$str2;
<span class="hljs-meta">?&gt;</span>
</code></pre>
<p><strong>strlen() &#x51FD;&#x6570;</strong></p>
<p>strlen() &#x51FD;&#x6570;&#x8FD4;&#x56DE;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x957F;&#x5EA6;&#xFF08;&#x5B57;&#x7B26;&#x6570;&#xFF09;&#x3002;</p>
<pre><code class="lang-php"><span class="hljs-meta">&lt;?php</span>
$username = <span class="hljs-string">&quot;zhangsan&quot;</span>;
<span class="hljs-keyword">echo</span> strlen($username);  <span class="hljs-comment">//echo 8</span>
</code></pre>
<h4 id="integer">integer</h4>
<p>&#x6574;&#x6570;&#x662F;&#x4E00;&#x4E2A;&#x6CA1;&#x6709;&#x5C0F;&#x6570;&#x7684;&#x6570;&#x5B57;&#x3002;</p>
<p>&#x6574;&#x578B;&#x53EF;&#x4EE5;&#x7528;&#x4E09;&#x79CD;&#x683C;&#x5F0F;&#x6765;&#x6307;&#x5B9A;&#xFF1A;&#x5341;&#x8FDB;&#x5236;&#xFF0C; &#x5341;&#x516D;&#x8FDB;&#x5236;&#xFF08; &#x4EE5; 0x &#x4E3A;&#x524D;&#x7F00;&#xFF09;&#x6216;&#x516B;&#x8FDB;&#x5236;&#xFF08;&#x524D;&#x7F00;&#x4E3A; 0&#xFF09;&#x3002;</p>
<pre><code class="lang-php"><span class="hljs-meta">&lt;?php</span>
    $x = <span class="hljs-number">5678</span>;
    var_dump($x);

    $y = <span class="hljs-number">-99999</span>;
    var_dump($y);

    $z = <span class="hljs-number">0xff</span>;
    var_dump($z);

    $k = <span class="hljs-number">066</span>;
    var_dump($k);
<span class="hljs-meta">?&gt;</span>
</code></pre>
<h4 id="float">float</h4>
<p>&#x6D6E;&#x70B9;&#x6570;&#x662F;&#x5E26;&#x5C0F;&#x6570;&#x90E8;&#x5206;&#x7684;&#x6570;&#x5B57;&#xFF0C;&#x6216;&#x662F;&#x6307;&#x6570;&#x5F62;&#x5F0F;&#x3002;</p>
<pre><code class="lang-php"><span class="hljs-meta">&lt;?php</span>
    $i = <span class="hljs-number">100</span>;
    var_dump($i);

    $k = <span class="hljs-number">10.1234</span>;
    var_dump($k);

    $l = <span class="hljs-number">2e3</span>;
    var_dump($l);

    $m = <span class="hljs-number">2e-3</span>;
    var_dump($m);
<span class="hljs-meta">?&gt;</span>
</code></pre>
<h3 id="&#x590D;&#x5408;&#x6570;&#x636E;&#x7C7B;&#x578B;">&#x590D;&#x5408;&#x6570;&#x636E;&#x7C7B;&#x578B;</h3>
<p>&#x5305;&#x62EC;&#x6570;&#x7EC4;array&#x548C;&#x5BF9;&#x8C61;object</p>
<p>&#x6570;&#x7EC4;&#x7C7B;&#x578B;&#xFF1A;&#x662F;&#x4E00;&#x4E2A;&#x6570;&#x636E;&#x96C6;&#x5408;&#xFF0C;&#x53EF;&#x4EE5;&#x5305;&#x62EC;&#x591A;&#x79CD;&#x6570;&#x636E;&#xFF1A;&#x6807;&#x91CF;&#x6570;&#x636E;&#x3001;&#x6570;&#x7EC4;&#x3001;&#x5BF9;&#x8C61;&#x3001;&#x8D44;&#x6E90;&#x3001;&#x53CA;PHP&#x4E2D;&#x652F;&#x6301;&#x7684;&#x5176;&#x4ED6;&#x8BED;&#x6CD5;&#x7ED3;&#x6784;&#x3002;</p>
<p>&#x6570;&#x7EC4;&#x4E2D;&#x6BCF;&#x4E2A;&#x6570;&#x636E;&#x6210;&#x4E3A;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#xFF0C;&#x5143;&#x7D20;&#x5305;&#x62EC;&#x7D22;&#x5F15;&#xFF08;&#x952E;&#x540D;&#xFF09;&#x548C;&#x503C;&#x4E24;&#x90E8;&#x5206;&#x3002;&#x5143;&#x7D20;&#x7D22;&#x5F15;&#x53EA;&#x80FD;&#x6709;&#x6570;&#x5B57;&#x6216;&#x5B57;&#x7B26;&#x4E32;&#x7EC4;&#x6210;&#x3002;&#x5143;&#x7D20;&#x503C;&#x53EF;&#x4EE5;&#x662F;&#x591A;&#x79CD;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x3002;</p>
<table>
<thead>
<tr>
<th>&#x7C7B;&#x578B;EN</th>
<th>&#x7C7B;&#x578B;CN</th>
<th>&#x503C;</th>
</tr>
</thead>
<tbody>
<tr>
<td>Array</td>
<td>&#x6570;&#x7EC4;</td>
<td>&#x6570;&#x7EC4;&#x5728;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;&#x4E2D;&#x5B58;&#x50A8;&#x591A;&#x4E2A;&#x503C;&#x3002;</td>
</tr>
<tr>
<td>Object</td>
<td>&#x5BF9;&#x8C61;</td>
<td>&#x5BF9;&#x8C61;&#x662F;&#x5B58;&#x50A8;&#x6570;&#x636E;&#x548C;&#x6709;&#x5173;&#x5982;&#x4F55;&#x5904;&#x7406;&#x6570;&#x636E;&#x7684;&#x4FE1;&#x606F;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x3002;&#x5BF9;&#x8C61;&#x662F;&#x7C7B;&#x7684;&#x5B9E;&#x4F8B;&#xFF0C;&#x7528;new&#x6765;&#x521B;&#x5EFA;</td>
</tr>
</tbody>
</table>
<pre><code>

</code></pre><h3 id="&#x7279;&#x6B8A;&#x6570;&#x636E;&#x7C7B;&#x578B;">&#x7279;&#x6B8A;&#x6570;&#x636E;&#x7C7B;&#x578B;</h3>
<p>&#x5305;&#x62EC;&#x7A7A;&#x503C;NULL&#x548C;&#x8D44;&#x6E90;resource</p>
<p>resource&#xFF1A;&#x8D44;&#x6E90;&#x662F;&#x7531;&#x4E13;&#x95E8;&#x7684;&#x51FD;&#x6570;&#x6765;&#x5EFA;&#x7ACB;&#x548C;&#x4F7F;&#x7528;&#x7684;&#xFF0C;&#x5B83;&#x662F;&#x4E00;&#x79CD;&#x7279;&#x6B8A;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;&#xFF0C;&#x5E76;&#x7531;&#x7A0B;&#x5E8F;&#x5458;&#x5206;&#x914D;&#x3002;&#x5728;&#x4F7F;&#x7528;&#x8D44;&#x6E90;&#x65F6;&#xFF0C;&#x8981;&#x53CA;&#x65F6;&#x91CA;&#x653E;&#x4E0D;&#x9700;&#x8981;&#x7684;&#x8D44;&#x6E90;&#x3002;&#x5982;&#x679C;&#x5FD8;&#x8BB0;&#x91CA;&#x653E;&#x8D44;&#x6E90;&#xFF0C;&#x7CFB;&#x7EDF;&#x81EA;&#x52A8;&#x542F;&#x52A8;&#x5783;&#x573E;&#x56DE;&#x6536;&#x673A;&#x5236;&#xFF0C;&#x907F;&#x514D;&#x5185;&#x5B58;&#x6D88;&#x8017;&#x6B86;&#x5C3D;&#x3002;</p>
<p>NULL&#xFF1A;&#x8868;&#x793A;&#x53D8;&#x91CF;&#x6CA1;&#x6709;&#x503C;&#x3002;NULL&#x4E0D;&#x533A;&#x5206;&#x5927;&#x5C0F;&#x5199;&#xFF0C;null&#x548C;NULL&#x90FD;&#x662F;&#x4E00;&#x6837;&#x3002; &#x4E3A;NULL&#x7684;&#x60C5;&#x51B5;&#xFF1A;</p>
<ul>
<li>&#x88AB;&#x8D4B;&#x4E3A;null&#xFF1B;</li>
<li>&#x5C1A;&#x672A;&#x88AB;&#x8D4B;&#x503C;&#xFF1B;</li>
<li>&#x901A;&#x8FC7;&#x51FD;&#x6570;unset&#xFF08;&#xFF09;&#x800C;&#x88AB;&#x9500;&#x6BC1;&#x3002;</li>
</ul>
<table>
<thead>
<tr>
<th>&#x7C7B;&#x578B;EN</th>
<th>&#x7C7B;&#x578B;CN</th>
<th>&#x503C;</th>
</tr>
</thead>
<tbody>
<tr>
<td>resource</td>
<td>&#x8D44;&#x6E90;</td>
<td>&#x8D44;&#x6E90;&#x662F;&#x7531;&#x4E13;&#x95E8;&#x7684;&#x51FD;&#x6570;&#x6765;&#x5EFA;&#x7ACB;&#x548C;&#x4F7F;&#x7528;&#x7684;&#xFF0C;&#x5B83;&#x662F;&#x4E00;&#x79CD;&#x7279;&#x6B8A;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;&#xFF0C;&#x5E76;&#x7531;&#x7A0B;&#x5E8F;&#x5458;&#x5206;&#x914D;&#x3002;</td>
</tr>
<tr>
<td>NULL</td>
<td>&#x7A7A;</td>
<td>&#x8868;&#x793A;&#x53D8;&#x91CF;&#x6CA1;&#x6709;&#x503C;&#x3002;NULL&#x4E0D;&#x533A;&#x5206;&#x5927;&#x5C0F;&#x5199;&#xFF0C;null&#x548C;NULL&#x90FD;&#x662F;&#x4E00;&#x6837;</td>
</tr>
</tbody>
</table>
<h2 id="&#x83B7;&#x53D6;&#x53D8;&#x91CF;&#x6570;&#x636E;&#x7C7B;&#x578B;">&#x83B7;&#x53D6;&#x53D8;&#x91CF;&#x6570;&#x636E;&#x7C7B;&#x578B;</h2>
<p>&#x901A;&#x8FC7;&#x51FD;&#x6570; gettype() &#x83B7;&#x53D6;&#x53D8;&#x91CF;&#x4E2D;&#x5B58;&#x50A8;&#x6570;&#x636E;&#x7684;&#x7C7B;&#x578B;&#x3002;</p>
<pre><code>gettype(var)
</code></pre><h2 id="&#x6570;&#x636E;&#x7C7B;&#x578B;&#x8F6C;&#x6362;">&#x6570;&#x636E;&#x7C7B;&#x578B;&#x8F6C;&#x6362;</h2>
<h3 id="typevalue">(type)value</h3>
<p>&#x8BED;&#x6CD5;&#xFF1A;</p>
<pre><code class="lang-php">(type)value

<span class="hljs-comment"># &#x793A;&#x4F8B;</span>
$initData = <span class="hljs-number">100</span>;
$bool = (bool)$initData;
</code></pre>
<table>
<thead>
<tr>
<th>&#x7C7B;&#x578B;&#x5173;&#x952E;&#x5B57;</th>
<th>&#x7C7B;&#x578B;&#x8F6C;&#x6362;</th>
</tr>
</thead>
<tbody>
<tr>
<td>int,integer</td>
<td>&#x8F6C;&#x6362;&#x6210;&#x6574;&#x578B;</td>
</tr>
<tr>
<td>float,double,real</td>
<td>&#x8F6C;&#x6362;&#x6210;&#x6D6E;&#x70B9;&#x578B;</td>
</tr>
<tr>
<td>bool,boolean</td>
<td>&#x8F6C;&#x6362;&#x6210;&#x5E03;&#x5C14;&#x578B;</td>
</tr>
<tr>
<td>string</td>
<td>&#x8F6C;&#x6362;&#x6210;&#x5B57;&#x7B26;&#x578B;</td>
</tr>
<tr>
<td>array</td>
<td>&#x6362;&#x6210;&#x6570;&#x7EC4;</td>
</tr>
<tr>
<td>object</td>
<td>&#x8F6C;&#x6362;&#x6210;&#x5BF9;&#x8C61;</td>
</tr>
</tbody>
</table>
<p>&#x6CE8;&#x610F;&#xFF1A;</p>
<h4 id="&#x8F6C;&#x6362;&#x4E3A;boolean&#xFF1A;">&#x8F6C;&#x6362;&#x4E3A;boolean&#xFF1A;</h4>
<p>&#x5F53;&#x8F6C;&#x6362;&#x4E3A; boolean &#x65F6;&#xFF0C;&#x4EE5;&#x4E0B;&#x503C;&#x88AB;&#x8BA4;&#x4E3A;&#x662F; FALSE &#xFF1A;</p>
<ul>
<li>&#x5E03;&#x5C14;&#x503C; FALSE &#x672C;&#x8EAB;</li>
<li>&#x6574;&#x578B;&#x503C; 0&#xFF08;&#x96F6;&#xFF09;</li>
<li>&#x6D6E;&#x70B9;&#x578B;&#x503C; 0.0&#xFF08;&#x96F6;&#xFF09;</li>
<li>&#x7A7A;&#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x4EE5;&#x53CA;&#x5B57;&#x7B26;&#x4E32; &quot;0&quot;</li>
<li>&#x4E0D;&#x5305;&#x62EC;&#x4EFB;&#x4F55;&#x5143;&#x7D20;&#x7684;&#x6570;&#x7EC4;</li>
<li>&#x4E0D;&#x5305;&#x62EC;&#x4EFB;&#x4F55;&#x6210;&#x5458;&#x53D8;&#x91CF;&#x7684;&#x5BF9;&#x8C61;&#xFF08;&#x4EC5; PHP 4.0 &#x9002;&#x7528;&#xFF09;</li>
<li>&#x7279;&#x6B8A;&#x7C7B;&#x578B; NULL&#xFF08;&#x5305;&#x62EC;&#x5C1A;&#x672A;&#x8D4B;&#x503C;&#x7684;&#x53D8;&#x91CF;&#xFF09;</li>
<li>&#x4ECE;&#x7A7A;&#x6807;&#x8BB0;&#x751F;&#x6210;&#x7684; SimpleXML &#x5BF9;&#x8C61;</li>
</ul>
<p>&#x6240;&#x6709;&#x5176;&#x5B83;&#x503C;&#x90FD;&#x88AB;&#x8BA4;&#x4E3A;&#x662F; TRUE &#xFF08;&#x5305;&#x62EC;&#x4EFB;&#x4F55;&#x8D44;&#x6E90;&#xFF09;&#x3002;</p>
<h4 id="&#x8F6C;&#x5316;&#x4E3A;integer&#xFF1A;">&#x8F6C;&#x5316;&#x4E3A;integer&#xFF1A;</h4>
<pre><code class="lang-php">- boolean&#xFF1A;<span class="hljs-keyword">false</span>&#x4E3A;<span class="hljs-number">0</span>&#xFF0C;<span class="hljs-keyword">true</span>&#x4E3A;<span class="hljs-number">1</span>
- float:&#x5C0F;&#x6570;&#x90E8;&#x5206;&#x88AB;&#x820D;&#x53BB;
- string:&#x4EE5;&#x6570;&#x5B57;&#x5F00;&#x5934;&#x5219;&#x622A;&#x53D6;&#x5230;&#x975E;&#x6570;&#x5B57;&#x4F4D;&#xFF0C;&#x5426;&#x5219;&#x8F93;&#x51FA;<span class="hljs-number">0</span>
</code></pre>
<h3 id="&#x901A;&#x8FC7;&#x51FD;&#x6570;settpye">&#x901A;&#x8FC7;&#x51FD;&#x6570;settpye()</h3>
<p>settype&#x4F1A;&#x6539;&#x53D8;&#x53D8;&#x91CF;&#x81EA;&#x8EAB;&#x7C7B;&#x578B;</p>
<pre><code class="lang-php">bool settpye&#xFF08;mixed <span class="hljs-keyword">var</span> , string type&#xFF09;
</code></pre>
<ul>
<li>var&#x4E3A;&#x6307;&#x5B9A;&#x53D8;&#x91CF;</li>
<li>type&#x4E3A;&#x8981;&#x8F6C;&#x6362;&#x7684;&#x7C7B;&#x578B; boolean/float/integer/string/array/null/object</li>
</ul>
<h2 id="&#x6570;&#x636E;&#x7C7B;&#x578B;&#x68C0;&#x6D4B;">&#x6570;&#x636E;&#x7C7B;&#x578B;&#x68C0;&#x6D4B;</h2>
<p>php&#x5185;&#x7F6E;&#x4E86;&#x68C0;&#x6D4B;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x7684;&#x7CFB;&#x5217;&#x51FD;&#x6570;</p>
<table>
<thead>
<tr>
<th>&#x51FD;&#x6570;</th>
<th>&#x4F5C;&#x7528;</th>
</tr>
</thead>
<tbody>
<tr>
<td>is_bool</td>
<td>&#x53D8;&#x91CF;&#x662F;&#x5426;&#x4E3A;&#x5E03;&#x5C14;&#x578B;</td>
</tr>
<tr>
<td>is_string</td>
<td>&#x53D8;&#x91CF;&#x662F;&#x5426;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;&#x7C7B;&#x578B;</td>
</tr>
<tr>
<td>is_float,is_double</td>
<td>&#x53D8;&#x91CF;&#x662F;&#x5426;&#x4E3A;&#x6D6E;&#x70B9;&#x578B;</td>
</tr>
<tr>
<td>is_integer,is_init</td>
<td>&#x53D8;&#x91CF;&#x662F;&#x5426;&#x4E3A;&#x6574;&#x578B;</td>
</tr>
<tr>
<td>is_null</td>
<td>&#x53D8;&#x91CF;&#x662F;&#x5426;&#x4E3A;null</td>
</tr>
<tr>
<td>is_array</td>
<td>&#x53D8;&#x91CF;&#x662F;&#x5426;&#x4E3A;&#x6570;&#x7EC4;</td>
</tr>
<tr>
<td>is_object</td>
<td>&#x53D8;&#x91CF;&#x662F;&#x5426;&#x4E3A;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;</td>
</tr>
<tr>
<td>is_numeric</td>
<td>&#x53D8;&#x91CF;&#x662F;&#x5426;&#x4E3A;&#x6570;&#x5B57;&#x6216;&#x7531;&#x6570;&#x5B57;&#x7EC4;&#x6210;&#x7684;&#x5B57;&#x7B26;&#x4E32;</td>
</tr>
</tbody>
</table>
<p>&#x793A;&#x4F8B;</p>
<pre><code class="lang-php"> $initData = <span class="hljs-number">100</span>;
 <span class="hljs-keyword">if</span>(is_init($initData)){
    <span class="hljs-keyword">echo</span> <span class="hljs-string">&quot;&#x6574;&#x578B;&quot;</span>;
 }<span class="hljs-keyword">else</span>{
     <span class="hljs-keyword">echo</span> <span class="hljs-string">&quot;&#x4E0D;&#x662F;&#x6574;&#x578B;&quot;</span>;
 }
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="03_php变量.html" class="navigation navigation-prev " aria-label="Previous page: php变量">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="05_php常量.html" class="navigation navigation-next " aria-label="Next page: php常量">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"php数据类型","level":"1.2.4","depth":2,"next":{"title":"php常量","level":"1.2.5","depth":2,"path":"php/php基础/05_php常量.md","ref":"./php/php基础/05_php常量.md","articles":[]},"previous":{"title":"php变量","level":"1.2.3","depth":2,"path":"php/php基础/03_php变量.md","ref":"./php/php基础/03_php变量.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["livereload"],"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"php/php基础/04_php数据类型.md","mtime":"2020-04-23T09:59:52.384Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-04-23T11:06:38.883Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

